import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: 'apk名称',
    align:"center",
    dataIndex: 'appName'
   },
   {
    title: '版本号',
    align:"center",
    dataIndex: 'version'
   },
   {
    title: '安装包地址',
    align:"center",
    dataIndex: 'appUrl',
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'appRemark'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "apk名称",
    field: "appName",
    component: 'JInput', 
  },
  {
    label: "版本号",
    field: "version",
    component: 'JInput', 
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: 'apk名称',
    field: 'appName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请输入apk名称!'},
      ];
    },
  },
  {
    label: '版本号',
    field: 'version',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请输入版本号!'},
      ];
    },
  },
  {
    label: '安装包地址',
    field: 'appUrl',
    component: 'JUpload',
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请上传安装包!'},
      ];
    },
    componentProps:{
      maxCount:1,
      multiple:false,
      bizPath:'apk',
    },
  },
  {
    label: '备注',
    field: 'appRemark',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  version: {title: '版本号',order: 0,view: 'text', type: 'string',},
  appUrl: {title: '安装包地址',order: 1,view: 'file', type: 'string',},
  appName: {title: 'apk名称',order: 2,view: 'text', type: 'string',},
  appRemark: {title: '备注',order: 3,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}


//表单数据
export const upGradeFormSchema: FormSchema[] = [
  {
    label: "apk版本",
    field: 'appVersionId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode:"school_bus_device_version,version,id"
   },
   dynamicRules: ({model,schema}) => {

  }
 },
  // {
  //   label: 'apk名称',
  //   field: 'appName',
  //   component: 'Input',
  // },
  {
    field: 'deviceName',
    component: 'JPopup',
    label: '设备',
    componentProps: ({ formActionType }) => {
      let { setFieldsValue } = formActionType
      return {
          setFieldsValue,
          placeholder: '请选择',
          code: 'choice_school_bus_device',
          fieldConfig: [{ source: 'id', target: 'deviceIds' }, { source: 'device_name', target: 'deviceName' }],
          multi: true,
      }
  },
},
{
  field: 'deviceIds',
  component: 'Input',
  label: 'popup回调值',
  colProps: {
      span: 8,
  },
  show:false
},
];